package medOffice.Gui;

import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import javax.swing.ButtonGroup;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.text.MaskFormatter;

import medOffice.Configuracoes;
import medOffice.Verificador;

/**
 * This code was edited or generated using CloudGarden's Jigloo
 * SWT/Swing GUI Builder, which is free for non-commercial
 * use. If Jigloo is being used commercially (ie, by a corporation,
 * company or business for any purpose whatever) then you
 * should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details.
 * Use of Jigloo implies acceptance of these licensing terms.
 * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
 * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
 * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
/**
 * Classe GUI do primeiro cadastro. É executado na primeira vez que o programa é
 * usado. Salva as informações em arquivos.
 * 
 * @author Ana Clara Lacerda - anacls@lcc.ufcg.edu.br
 * @version 0.2 - 01/12/2009
 * 
 */
public class CadastramentoInicial {

	private List<String> minhaClinica;
	private List<String> meuMedico;

	private boolean executarDepois = false;;
	private JLabel formatoNascimento;
	private JButton botaoTer;
	private JTextArea explicacao;
	private ButtonGroup escolhaSexo;
	private JRadioButton sexoM;
	private JRadioButton sexoF;
	private JButton limpa2;
	private JTextArea aboutMedico;
	private JTextArea passo3;
	private JTextArea saudacao2;
	private JTextArea passo2;
	private JTextArea saudacao;
	private JButton limpar1;
	private JTextArea proximoPasso;
	private JTextArea aboutMedOffice;
	private JTextArea jTextArea1;
	private JLabel trabalho;
	private JCheckBox trabalhaTerca;
	private JCheckBox trabalhaSabado;
	private JCheckBox trabalhaSexta;
	private JCheckBox trabalhaQuinta;
	private JCheckBox trabalhaQuarta;
	private JCheckBox trabalhaSegunda;
	private JCheckBox tDom;
	private JLabel labelSaida;
	private JLabel labelEntrada;
	private JLabel nomehorarios;
	private JButton botaoSab;
	private JButton botaoSex;
	private JTextArea aboutClinica;
	private JCheckBox executa;
	private JTextArea informacao;
	private JTextArea saudacao4;
	private JButton botaoQui;
	private JButton botaoQuarta;
	private JButton botaoSeg;
	private JButton botaoDom;

	private List<String> hSeg, hTer, hQua, hQui, hSex, hSab, hDom;

	private JFrame frame;
	private JFrame frame1;
	private JFrame frame2;
	private JFrame frame3;
	private JFrame frame4;
	private JFrame frame5;
	private int posicaoX, posicaoY;

	private JButton proximo;
	private JButton anterior;
	private JButton finalizar;
	private JButton limpar;
	private JComboBox dddTel;

	private final String[] ARRAY_DDD = { "DDD", "11", "12", "13", "14", "15",
			"16", "17", "18", "19", "21", "22", "24", "27", "28", "31", "32",
			"33", "34", "35", "37", "38", "41", "42", "43", "44", "45", "46",
			"47", "48", "49", "51", "53", "54", "55", "61", "62", "63", "64",
			"65", "66", "67", "68", "69", "71", "73", "74", "75", "77", "79",
			"81", "82", "83", "84", "85", "86", "87", "88", "89", "91", "92",
			"93", "94", "95", "96", "97", "98", "99" };

	/**
	 * Executa o primeiro frame do cadastro. Frame de Boas Vindas.
	 */
	public void inicializa() {
		if (frame != null) {
			frame.setVisible(true);
		} else {
			frame = new JFrame("MedOffice - Cadastramento Inicial");
			JPanel panel = new JPanel();
			GroupLayout panelLayout2 = new GroupLayout((JComponent) panel);
			panel.setLayout(panelLayout2);
			JLabel texto = new JLabel("Bem vindo ao MedOffice!");
			texto.setFont(new java.awt.Font("Purisa", 1, 16));
			texto.setForeground(new java.awt.Color(21, 130, 21));
			proximo = new JButton("Próximo ->");
			proximo.setForeground(new java.awt.Color(85, 232, 85));
			proximo.setBackground(new java.awt.Color(14, 71, 14));
			panelLayout2
					.setVerticalGroup(panelLayout2
							.createSequentialGroup()
							.addContainerGap(28, 28)
							.addComponent(texto, GroupLayout.PREFERRED_SIZE,
									31, GroupLayout.PREFERRED_SIZE)
							.addGap(35)
							.addComponent(getAboutMedOffice(),
									GroupLayout.PREFERRED_SIZE, 138,
									GroupLayout.PREFERRED_SIZE)
							.addGap(241)
							.addGroup(
									panelLayout2
											.createParallelGroup()
											.addGroup(
													panelLayout2
															.createSequentialGroup()
															.addComponent(
																	getProximoPasso(),
																	GroupLayout.PREFERRED_SIZE,
																	54,
																	GroupLayout.PREFERRED_SIZE)
															.addGap(
																	0,
																	0,
																	Short.MAX_VALUE))
											.addGroup(
													GroupLayout.Alignment.LEADING,
													panelLayout2
															.createSequentialGroup()
															.addGap(
																	0,
																	8,
																	Short.MAX_VALUE)
															.addComponent(
																	proximo,
																	GroupLayout.PREFERRED_SIZE,
																	GroupLayout.PREFERRED_SIZE,
																	GroupLayout.PREFERRED_SIZE)
															.addGap(25)))
							.addContainerGap(43, 43));
			panelLayout2
					.setHorizontalGroup(panelLayout2
							.createSequentialGroup()
							.addContainerGap()
							.addGroup(
									panelLayout2
											.createParallelGroup()
											.addComponent(
													getAboutMedOffice(),
													GroupLayout.Alignment.LEADING,
													GroupLayout.PREFERRED_SIZE,
													978,
													GroupLayout.PREFERRED_SIZE)
											.addGroup(
													GroupLayout.Alignment.LEADING,
													panelLayout2
															.createSequentialGroup()
															.addGroup(
																	panelLayout2
																			.createParallelGroup()
																			.addGroup(
																					GroupLayout.Alignment.LEADING,
																					panelLayout2
																							.createSequentialGroup()
																							.addGap(
																									55)
																							.addComponent(
																									getProximoPasso(),
																									GroupLayout.PREFERRED_SIZE,
																									393,
																									GroupLayout.PREFERRED_SIZE))
																			.addGroup(
																					GroupLayout.Alignment.LEADING,
																					panelLayout2
																							.createSequentialGroup()
																							.addComponent(
																									texto,
																									GroupLayout.PREFERRED_SIZE,
																									321,
																									GroupLayout.PREFERRED_SIZE)
																							.addGap(
																									127)))
															.addGap(137)
															.addComponent(
																	proximo,
																	GroupLayout.PREFERRED_SIZE,
																	GroupLayout.PREFERRED_SIZE,
																	GroupLayout.PREFERRED_SIZE)
															.addGap(
																	0,
																	312,
																	Short.MAX_VALUE))));
			frame.add(panel);
			panel.setBackground(new java.awt.Color(191, 236, 191));

			mostraNaTela(frame);

			proximo.addActionListener((new java.awt.event.ActionListener() {
				@Override
				public void actionPerformed(ActionEvent arg0) {
					primeiraEtapa();
					frame.setVisible(false);
				}
			}));
		}

	}

	/**
	 * Executa o frame da primeira etapa do cadastro. Cadastro da Clinica
	 */
	public void primeiraEtapa() {
		if (frame1 != null) {
			frame1.setVisible(true);
		} else {
			frame1 = new JFrame("Primeira Etapa - Cadastro da Clinica");
			JPanel panel = new JPanel();
			GroupLayout panelLayout1 = new GroupLayout((JComponent) panel);
			panel.setLayout(panelLayout1);
			proximo = new JButton("Próximo ->");
			proximo.setBackground(new java.awt.Color(14, 71, 14));
			proximo.setSize(91, 21);
			proximo.setForeground(new java.awt.Color(85, 232, 85));
			anterior = new JButton("<- Anterior");
			anterior.setBackground(new java.awt.Color(14, 71, 14));
			anterior.setSize(91, 21);
			anterior.setForeground(new java.awt.Color(85, 232, 85));

			final JTextField nome = new JTextField("", 20);
			final JTextField endereco = new JTextField("", 20);
			final JFormattedTextField telefone = new JFormattedTextField(createFormatter("####-####"));
			ComboBoxModel dddTelModel = new DefaultComboBoxModel(ARRAY_DDD);
			dddTel = new JComboBox();
			dddTel.setModel(dddTelModel);
			dddTel.setMaximumRowCount(25);

			JLabel labelNome = new JLabel("*Nome da Clinica: ");
			JLabel labelEndereco = new JLabel("*Endereco: ");
			JLabel labelTelefone = new JLabel("*Telefone: ");
			panelLayout1.setVerticalGroup(panelLayout1.createSequentialGroup()
					.addContainerGap(26, 26).addComponent(getSaudacao(),
							GroupLayout.PREFERRED_SIZE, 36,
							GroupLayout.PREFERRED_SIZE).addPreferredGap(
							LayoutStyle.ComponentPlacement.UNRELATED)
					.addComponent(getPasso2(), GroupLayout.PREFERRED_SIZE, 85,
							GroupLayout.PREFERRED_SIZE).addGap(46).addGroup(
							panelLayout1.createParallelGroup(
									GroupLayout.Alignment.BASELINE)
									.addComponent(nome,
											GroupLayout.Alignment.BASELINE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE)
									.addComponent(labelNome,
											GroupLayout.Alignment.BASELINE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE))
					.addGap(24).addGroup(
							panelLayout1.createParallelGroup(
									GroupLayout.Alignment.BASELINE)
									.addComponent(endereco,
											GroupLayout.Alignment.BASELINE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE)
									.addComponent(labelEndereco,
											GroupLayout.Alignment.BASELINE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE))
					.addGap(31).addGroup(
							panelLayout1.createParallelGroup(
									GroupLayout.Alignment.BASELINE)
									.addComponent(dddTel,
											GroupLayout.Alignment.BASELINE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE)
									.addComponent(labelTelefone,
											GroupLayout.Alignment.BASELINE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE)
									.addComponent(telefone,
											GroupLayout.Alignment.BASELINE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE)
									)
					.addGap(126).addGroup(
							panelLayout1.createParallelGroup(
									GroupLayout.Alignment.BASELINE)
									.addComponent(anterior,
											GroupLayout.Alignment.BASELINE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE)
									.addComponent(proximo,
											GroupLayout.Alignment.BASELINE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE)
									.addComponent(getLimpar1(),
											GroupLayout.Alignment.BASELINE,
											GroupLayout.PREFERRED_SIZE, 21,
											GroupLayout.PREFERRED_SIZE))
					.addContainerGap(100, 100));
			panelLayout1
					.setHorizontalGroup(panelLayout1
							.createSequentialGroup()
							.addContainerGap(32, 32)
							.addGroup(
									panelLayout1
											.createParallelGroup()
											.addGroup(
													GroupLayout.Alignment.LEADING,
													panelLayout1
															.createSequentialGroup()
															.addGroup(
																	panelLayout1
																			.createParallelGroup()
																			.addGroup(
																					panelLayout1
																							.createSequentialGroup()
																							.addGroup(
																									panelLayout1
																											.createParallelGroup()
																											.addComponent(
																													labelNome,
																													GroupLayout.Alignment.LEADING,
																													GroupLayout.PREFERRED_SIZE,
																													GroupLayout.PREFERRED_SIZE,
																													GroupLayout.PREFERRED_SIZE)
																											.addGroup(
																													GroupLayout.Alignment.LEADING,
																													panelLayout1
																															.createSequentialGroup()
																															.addComponent(
																																	labelTelefone,
																																	GroupLayout.PREFERRED_SIZE,
																																	GroupLayout.PREFERRED_SIZE,
																																	GroupLayout.PREFERRED_SIZE)
																															.addGap(
																																	46))
																											.addGroup(
																													GroupLayout.Alignment.LEADING,
																													panelLayout1
																															.createSequentialGroup()
																															.addComponent(
																																	labelEndereco,
																																	GroupLayout.PREFERRED_SIZE,
																																	GroupLayout.PREFERRED_SIZE,
																																	GroupLayout.PREFERRED_SIZE)
																															.addGap(
																																	40)))
																							.addPreferredGap(
																									LayoutStyle.ComponentPlacement.RELATED)
																							.addGroup(
																									panelLayout1
																											.createParallelGroup()
																											.addGroup(
																													GroupLayout.Alignment.LEADING,
																													panelLayout1
																															.createSequentialGroup()
																															.addComponent(
																																	dddTel,
																																	GroupLayout.PREFERRED_SIZE,
																																	GroupLayout.PREFERRED_SIZE,
																																	GroupLayout.PREFERRED_SIZE)
																															.addGap(
																																	16)
																															.addComponent(
																																	telefone,
																																	GroupLayout.PREFERRED_SIZE,
																																	70,
																																	GroupLayout.PREFERRED_SIZE)
																															.addPreferredGap(
																																	LayoutStyle.ComponentPlacement.UNRELATED)
																															)
																											.addComponent(
																													endereco,
																													GroupLayout.Alignment.LEADING,
																													GroupLayout.PREFERRED_SIZE,
																													GroupLayout.PREFERRED_SIZE,
																													GroupLayout.PREFERRED_SIZE)
																											.addComponent(
																													nome,
																													GroupLayout.Alignment.LEADING,
																													GroupLayout.PREFERRED_SIZE,
																													GroupLayout.PREFERRED_SIZE,
																													GroupLayout.PREFERRED_SIZE)))
																			.addGroup(
																					GroupLayout.Alignment.LEADING,
																					panelLayout1
																							.createSequentialGroup()
																							.addComponent(
																									getSaudacao(),
																									GroupLayout.PREFERRED_SIZE,
																									306,
																									GroupLayout.PREFERRED_SIZE)
																							.addGap(
																									46)))
															.addComponent(
																	getLimpar1(),
																	GroupLayout.PREFERRED_SIZE,
																	91,
																	GroupLayout.PREFERRED_SIZE))
											.addGroup(
													GroupLayout.Alignment.LEADING,
													panelLayout1
															.createSequentialGroup()
															.addPreferredGap(
																	labelTelefone,
																	getPasso2(),
																	LayoutStyle.ComponentPlacement.INDENT)
															.addComponent(
																	getPasso2(),
																	GroupLayout.PREFERRED_SIZE,
																	424,
																	GroupLayout.PREFERRED_SIZE)
															.addGap(7)))
							.addGap(26).addComponent(anterior,
									GroupLayout.PREFERRED_SIZE,
									GroupLayout.PREFERRED_SIZE,
									GroupLayout.PREFERRED_SIZE).addGap(18)
							.addComponent(proximo, GroupLayout.PREFERRED_SIZE,
									GroupLayout.PREFERRED_SIZE,
									GroupLayout.PREFERRED_SIZE)
							.addContainerGap(108, Short.MAX_VALUE));

			limpar1.addActionListener((new java.awt.event.ActionListener() {
				@Override
				public void actionPerformed(ActionEvent arg0) {
					nome.setText("");
					endereco.setText("");
					telefone.setText("");
					dddTel.setSelectedIndex(0);
				}
			}));
			frame1.add(panel);
			panel.setBackground(new java.awt.Color(191, 236, 191));
			mostraNaTela(frame1);

			anterior.addActionListener((new java.awt.event.ActionListener() {
				@Override
				public void actionPerformed(ActionEvent arg0) {
					inicializa();
					frame1.setVisible(false);
				}

			}));

			proximo.addActionListener((new java.awt.event.ActionListener() {
				@Override
				public void actionPerformed(ActionEvent arg0) {
					try {
						String telefoneClinica = "("
								+ (String) dddTel.getSelectedItem() + ") "
								+ telefone.getText();
						criaClinica(nome.getText(), endereco.getText(),
								telefoneClinica);
						segundaEtapa();
						frame1.setVisible(false);
					} catch (Exception e) {
						JOptionPane.showMessageDialog(frame1, e.getMessage(),
								"Atenção!", JOptionPane.PLAIN_MESSAGE);
					}
				}

			}));
		}

	}

	/**
	 * Executa a segunda etapa do cadastro. Dados sobre o Medico
	 */
	public void segundaEtapa() {
		{
			frame2 = new JFrame("Segunda Etapa - Cadastramento do Médico");

			proximo = new JButton("Próximo ->");
			proximo.setBackground(new java.awt.Color(14, 71, 14));
			proximo.setForeground(new java.awt.Color(85, 232, 85));
			proximo.setBounds(601, 445, 81, 21);
			anterior = new JButton("<- Anterior");
			anterior.setBackground(new java.awt.Color(14, 71, 14));
			anterior.setForeground(new java.awt.Color(85, 232, 85));
			anterior.setBounds(551, 445, 81, 21);
			limpar = new JButton("Limpar");
			JPanel panel = new JPanel();
			GroupLayout panelLayout = new GroupLayout((JComponent) panel);
			panel.setLayout(panelLayout);

			final JTextField nome = new JTextField("", 20);
			final JFormattedTextField CPF = new JFormattedTextField(createFormatter("#########-##"));
			final JTextField endereco = new JTextField("", 20);
			final JFormattedTextField telefone = new JFormattedTextField(createFormatter("####-####"));
			final JTextField email = new JTextField("", 20);
			final JFormattedTextField dataDeNascimento = new JFormattedTextField(createFormatter("##/##/####"));
			final JFormattedTextField consulta = new JFormattedTextField(createFormatter("##:##"));
			final JFormattedTextField retorno = new JFormattedTextField(createFormatter("##:##"));
			ComboBoxModel dddTelModel = new DefaultComboBoxModel(ARRAY_DDD);
			dddTel = new JComboBox();
			dddTel.setModel(dddTelModel);
			dddTel.setMaximumRowCount(25);

			JLabel labelNome = new JLabel("*Nome: ");
			{
				formatoNascimento = new JLabel();
				formatoNascimento.setText("(dd/mm/aaaa) :");
			}
			JLabel labelCPF = new JLabel("*CPF: ");
			JLabel labelEndereco = new JLabel("Endereco: ");
			JLabel labelTelefone = new JLabel("Telefone: ");
			labelTelefone.setText("*Telefone: ");
			JLabel labelEmail = new JLabel("Email: ");
			JLabel labelData = new JLabel("Data de nascimento (dd/mm/aaaa): ");
			labelData.setText("*Data de nascimento");
			JLabel labelSexo = new JLabel("Sexo (M/F): ");
			labelSexo.setText("*Sexo : ");
			getEscolhaSexo().add(getSexoF());
			getEscolhaSexo().add(getSexoM());

			JLabel labelConsulta = new JLabel("Tempo de consulta (hh:mm) : ");
			labelConsulta.setText("*Tempo de consulta (hh:mm) : ");
			JLabel labelRetorno = new JLabel("Tempo de retorno (hh:mm) : ");
			labelRetorno.setText("*Tempo de retorno  (hh:mm) : ");
			panelLayout.setVerticalGroup(panelLayout.createSequentialGroup()
				.addContainerGap(28, 28)
				.addComponent(getSaudacao2(), GroupLayout.PREFERRED_SIZE, 46, GroupLayout.PREFERRED_SIZE)
				.addGap(46)
				.addGroup(panelLayout.createParallelGroup()
				    .addGroup(panelLayout.createSequentialGroup()
				        .addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				            .addComponent(nome, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				            .addComponent(labelNome, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
				        .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				        .addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				            .addComponent(CPF, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
				            .addComponent(labelCPF, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
				        .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				        .addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				            .addComponent(endereco, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				            .addComponent(labelEndereco, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)))
				    .addComponent(getPasso3(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE))
				.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(dddTel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addComponent(labelTelefone, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)
				    .addComponent(telefone, GroupLayout.Alignment.BASELINE, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
				.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
				.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(email, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addComponent(labelEmail, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
				.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
				.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(dataDeNascimento, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addComponent(labelData, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
				.addGroup(panelLayout.createParallelGroup()
				    .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				        .addComponent(formatoNascimento, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
				        .addGap(8))
				    .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				        .addGap(10)
				        .addComponent(getSexoF(), GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)))
				.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
				.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(getSexoM(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addComponent(labelSexo, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
				.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(consulta, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addComponent(labelConsulta, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
				.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(retorno, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
				    .addComponent(labelRetorno, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
				.addGap(78)
				.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(anterior, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
				    .addComponent(proximo, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
				    .addComponent(getLimpa2(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE))
				.addContainerGap(62, 62));
			panelLayout.setHorizontalGroup(panelLayout.createSequentialGroup()
				.addContainerGap(22, 22)
				.addGroup(panelLayout.createParallelGroup()
				    .addGroup(panelLayout.createSequentialGroup()
				        .addGroup(panelLayout.createParallelGroup()
				            .addComponent(labelConsulta, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				            .addComponent(labelRetorno, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                .addComponent(formatoNascimento, GroupLayout.PREFERRED_SIZE, 127, GroupLayout.PREFERRED_SIZE)
				                .addGap(67))
				            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                .addComponent(labelData, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                .addGap(61)))
				        .addGroup(panelLayout.createParallelGroup()
				            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                .addGroup(panelLayout.createParallelGroup()
				                    .addComponent(retorno, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                    .addComponent(consulta, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
				                .addGap(0, 28, Short.MAX_VALUE)
				                .addComponent(getLimpa2(), GroupLayout.PREFERRED_SIZE, 89, GroupLayout.PREFERRED_SIZE))
				            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                .addComponent(getSexoM(), GroupLayout.PREFERRED_SIZE, 106, GroupLayout.PREFERRED_SIZE)
				                .addGap(0, 83, Short.MAX_VALUE))
				            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                .addComponent(getSexoF(), GroupLayout.PREFERRED_SIZE, 106, GroupLayout.PREFERRED_SIZE)
				                .addGap(0, 83, Short.MAX_VALUE))
				            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                .addComponent(dataDeNascimento, GroupLayout.PREFERRED_SIZE, 118, GroupLayout.PREFERRED_SIZE)
				                .addGap(0, 71, Short.MAX_VALUE))))
				    .addGroup(panelLayout.createSequentialGroup()
				        .addGroup(panelLayout.createParallelGroup()
				            .addComponent(labelTelefone, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 73, GroupLayout.PREFERRED_SIZE)
				            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                .addComponent(labelSexo, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                .addGap(25))
				            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                .addComponent(labelEmail, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                .addGap(32))
				            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                .addComponent(labelEndereco, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED))
				            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                .addComponent(labelCPF, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                .addGap(36))
				            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                .addComponent(labelNome, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                .addGap(23)))
				        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
				        .addGroup(panelLayout.createParallelGroup()
				            .addGroup(panelLayout.createSequentialGroup()
				                .addComponent(email, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                .addGap(0, 0, Short.MAX_VALUE))
				            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                .addComponent(dddTel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                .addGap(16)
				                .addComponent(telefone, GroupLayout.PREFERRED_SIZE, 114, GroupLayout.PREFERRED_SIZE)
				                .addGap(0, 46, Short.MAX_VALUE))
				            .addGroup(panelLayout.createSequentialGroup()
				                .addComponent(endereco, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                .addGap(0, 0, Short.MAX_VALUE))
				            .addGroup(panelLayout.createSequentialGroup()
				                .addComponent(CPF, GroupLayout.PREFERRED_SIZE, 226, GroupLayout.PREFERRED_SIZE)
				                .addGap(0, 0, Short.MAX_VALUE))
				            .addGroup(panelLayout.createSequentialGroup()
				                .addComponent(nome, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                .addGap(0, 0, Short.MAX_VALUE)))
				        .addGap(71))
				    .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				        .addComponent(getSaudacao2(), GroupLayout.PREFERRED_SIZE, 299, GroupLayout.PREFERRED_SIZE)
				        .addGap(0, 84, Short.MAX_VALUE)))
				.addGroup(panelLayout.createParallelGroup()
				    .addComponent(getPasso3(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 349, GroupLayout.PREFERRED_SIZE)
				    .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				        .addGap(0, 32, GroupLayout.PREFERRED_SIZE)
				        .addComponent(anterior, GroupLayout.PREFERRED_SIZE, 132, GroupLayout.PREFERRED_SIZE)
				        .addGap(20)
				        .addComponent(proximo, GroupLayout.PREFERRED_SIZE, 130, GroupLayout.PREFERRED_SIZE)
				        .addGap(35)))
				.addContainerGap(36, 36));

			frame2.add(panel);
			panel.setBackground(new java.awt.Color(191, 236, 191));
			mostraNaTela(frame2);

			limpa2.addActionListener((new java.awt.event.ActionListener() {
				@Override
				public void actionPerformed(ActionEvent arg0) {
					nome.setText("");
					CPF.setText("");
					endereco.setText("");
					telefone.setText("");
					email.setText("");
					dataDeNascimento.setText("");
					getEscolhaSexo().clearSelection();
					dddTel.setSelectedIndex(0);
				}

			}));

			anterior.addActionListener((new java.awt.event.ActionListener() {
				@Override
				public void actionPerformed(ActionEvent arg0) {
					frame2.setVisible(false);
					primeiraEtapa();
				}

			}));

			proximo.addActionListener((new java.awt.event.ActionListener() {
				@Override
				public void actionPerformed(ActionEvent arg0) {
					try {
						String sexoEscolhido = "";
						if (getSexoM().isSelected())
							sexoEscolhido = "M";
						if (getSexoF().isSelected())
							sexoEscolhido = "F";

						String telefoneMedico = "("
								+ (String) dddTel.getSelectedItem() + ") "
								+ telefone.getText();
						criaMedico(nome.getText(), CPF.getText(), endereco
								.getText(), email.getText(), telefoneMedico,
								sexoEscolhido, dataDeNascimento.getText(),
								consulta.getText(), retorno.getText());
						frame2.setVisible(false);
						terceiraEtapa();
					} catch (Exception e) {
						JOptionPane.showMessageDialog(frame1, e.getMessage(),
								"Atenção!", JOptionPane.PLAIN_MESSAGE);
					}
				}

			}));
		}

	}

	/**
	 * Executa o frame da terceira etapa do cadastro. Horários de trabalho.
	 */
	public void terceiraEtapa() {
//		if (frame3 != null) {
//			frame3.setVisible(true);
//		} else 
		{
			frame3 = new JFrame("Terceira Etapa - Sobre o Médico");
			{
				final JPanel panel = new JPanel();
				frame3.getContentPane().add(panel);
				GroupLayout panelLayout3 = new GroupLayout((JComponent) panel);
				panel.setLayout(panelLayout3);
				panel.setBackground(new java.awt.Color(191, 236, 191));
				{
					anterior = new JButton("<- Anterior");
					anterior.setBackground(new java.awt.Color(14, 71, 14));
					anterior.setForeground(new java.awt.Color(85, 232, 85));
					anterior
							.addActionListener((new java.awt.event.ActionListener() {
								@Override
								public void actionPerformed(ActionEvent arg0) {
									frame3.setVisible(false);
									segundaEtapa();
								}

							}));
				}

				{
					botaoQuarta = new JButton();
					botaoQuarta.setText("QUA");
					botaoQuarta.setSize(67, 34);
					botaoQuarta.setBackground(new java.awt.Color(37, 101, 37));
					botaoQuarta
							.setForeground(new java.awt.Color(144, 238, 144));
				}
				{
					botaoTer = new JButton();
					botaoTer.setText("TER");
					botaoTer.setSize(67, 34);
					botaoTer.setBackground(new java.awt.Color(37, 101, 37));
					botaoTer.setForeground(new java.awt.Color(144, 238, 144));
				}
				{
					botaoSab = new JButton();
					botaoSab.setText("SAB");
					botaoSab.setSize(67, 34);
					botaoSab.setBackground(new java.awt.Color(37, 101, 37));
					botaoSab.setForeground(new java.awt.Color(144, 238, 144));
				}
				{
					botaoSeg = new JButton();
					botaoSeg.setText("SEG");
					botaoSeg.setSize(67, 34);
					botaoSeg.setBackground(new java.awt.Color(37, 101, 37));
					botaoSeg.setForeground(new java.awt.Color(144, 238, 144));
				}
				{
					botaoSex = new JButton();
					botaoSex.setText("SEX");
					botaoSex.setSize(67, 34);
					botaoSex.setBackground(new java.awt.Color(37, 101, 37));
					botaoSex.setForeground(new java.awt.Color(144, 238, 144));
				}
				{
					botaoDom = new JButton();
					botaoDom.setText("DOM");
					botaoDom.setBackground(new java.awt.Color(37, 101, 37));
					botaoDom.setForeground(new java.awt.Color(144, 238, 144));
				}
				{
					botaoQui = new JButton();
					botaoQui.setText("QUI");
					botaoQui.setSize(67, 34);
					botaoQui.setBackground(new java.awt.Color(37, 101, 37));
					botaoQui.setForeground(new java.awt.Color(144, 238, 144));
				}
				{
					proximo = new JButton("Próximo ->");
					proximo.setBackground(new java.awt.Color(14, 71, 14));
					proximo.setForeground(new java.awt.Color(85, 232, 85));
					proximo
							.addActionListener((new java.awt.event.ActionListener() {
								@Override
								public void actionPerformed(ActionEvent arg0) {
									frame3.setVisible(false);
									ultimaEtapa();

								}

							}));
				}
				botaoSeg
						.addActionListener((new java.awt.event.ActionListener() {
							@Override
							public void actionPerformed(ActionEvent arg0) {
								if (trabalhaSegunda.isSelected()) {
									if (hSeg == null) {
										hSeg = new ArrayList<String>();
									}
									capturaHorarios(hSeg);
								} else {
									JOptionPane
											.showMessageDialog(
													frame3,
													"Segunda-Feira não está marcada como dia de trabalho",
													"Atenção!",
													JOptionPane.PLAIN_MESSAGE);
								}
							}

						}));

				botaoTer
						.addActionListener((new java.awt.event.ActionListener() {
							@Override
							public void actionPerformed(ActionEvent arg0) {
								if (trabalhaTerca.isSelected()) {
									if (hTer == null) {
										hTer = new ArrayList<String>();
									}
									capturaHorarios(hTer);
								} else {
									JOptionPane
											.showMessageDialog(
													frame3,
													"Terça-Feira não está marcada como dia de trabalho",
													"Atenção!",
													JOptionPane.PLAIN_MESSAGE);
								}
							}

						}));

				botaoQuarta
						.addActionListener((new java.awt.event.ActionListener() {
							@Override
							public void actionPerformed(ActionEvent arg0) {
								if (trabalhaQuarta.isSelected()) {
									if (hQua == null) {
										hQua = new ArrayList<String>();
									}
									capturaHorarios(hQua);
								} else {
									JOptionPane
											.showMessageDialog(
													frame3,
													"Quarta-Feira não está marcada como dia de trabalho",
													"Atenção!",
													JOptionPane.PLAIN_MESSAGE);
								}
							}

						}));

				botaoQui
						.addActionListener((new java.awt.event.ActionListener() {
							@Override
							public void actionPerformed(ActionEvent arg0) {
								if (trabalhaQuinta.isSelected()) {
									if (hQui == null) {
										hQui = new ArrayList<String>();
									}
									capturaHorarios(hQui);
								} else {
									JOptionPane
											.showMessageDialog(
													frame3,
													"Quinta-Feira não está marcada como dia de trabalho",
													"Atenção!",
													JOptionPane.PLAIN_MESSAGE);
								}
							}

						}));

				botaoSex
						.addActionListener((new java.awt.event.ActionListener() {
							@Override
							public void actionPerformed(ActionEvent arg0) {
								if (trabalhaSexta.isSelected()) {
									if (hSex == null) {
										hSex = new ArrayList<String>();
									}
									capturaHorarios(hSex);
								} else {
									JOptionPane
											.showMessageDialog(
													frame3,
													"Sexta-Feira não está marcada como dia de trabalho",
													"Atenção!",
													JOptionPane.PLAIN_MESSAGE);
								}
							}

						}));

				botaoSab
						.addActionListener((new java.awt.event.ActionListener() {
							@Override
							public void actionPerformed(ActionEvent arg0) {
								if (trabalhaSabado.isSelected()) {
									if (hSab == null) {
										hSab = new ArrayList<String>();
									}
									capturaHorarios(hSab);
								} else {
									JOptionPane
											.showMessageDialog(
													frame3,
													"Sabado não está marcado como dia de trabalho",
													"Atenção!",
													JOptionPane.PLAIN_MESSAGE);
								}
							}

						}));

				botaoDom
						.addActionListener((new java.awt.event.ActionListener() {
							@Override
							public void actionPerformed(ActionEvent arg0) {
								if (tDom.isSelected()) {
									if (hDom == null) {
										hDom = new ArrayList<String>();
									}
									capturaHorarios(hDom);
								} else {
									JOptionPane
											.showMessageDialog(
													frame3,
													"Domingo não está marcado como dia de trabalho",
													"Atenção!",
													JOptionPane.PLAIN_MESSAGE);
								}
							}

						}));
				panelLayout3
						.setHorizontalGroup(panelLayout3
								.createSequentialGroup()
								.addComponent(limpar,
										GroupLayout.PREFERRED_SIZE, 0,
										GroupLayout.PREFERRED_SIZE)
								.addGap(36)
								.addGroup(
										panelLayout3
												.createParallelGroup()
												.addGroup(
														GroupLayout.Alignment.LEADING,
														panelLayout3
																.createSequentialGroup()
																.addComponent(
																		getNomehorarios(),
																		GroupLayout.PREFERRED_SIZE,
																		228,
																		GroupLayout.PREFERRED_SIZE)
																.addGap(
																		0,
																		458,
																		Short.MAX_VALUE))
												.addGroup(
														panelLayout3
																.createSequentialGroup()
																.addGroup(
																		panelLayout3
																				.createParallelGroup()
																				.addComponent(
																						getTrabalho(),
																						GroupLayout.Alignment.LEADING,
																						GroupLayout.PREFERRED_SIZE,
																						181,
																						GroupLayout.PREFERRED_SIZE)
																				.addGroup(
																						panelLayout3
																								.createSequentialGroup()
																								.addGap(
																										20)
																								.addGroup(
																										panelLayout3
																												.createParallelGroup()
																												.addGroup(
																														GroupLayout.Alignment.LEADING,
																														panelLayout3
																																.createSequentialGroup()
																																.addComponent(
																																		getJCheckBox1x(),
																																		GroupLayout.PREFERRED_SIZE,
																																		GroupLayout.PREFERRED_SIZE,
																																		GroupLayout.PREFERRED_SIZE)
																																.addGap(
																																		52))
																												.addGroup(
																														GroupLayout.Alignment.LEADING,
																														panelLayout3
																																.createSequentialGroup()
																																.addComponent(
																																		getJCheckBox3(),
																																		GroupLayout.PREFERRED_SIZE,
																																		GroupLayout.PREFERRED_SIZE,
																																		GroupLayout.PREFERRED_SIZE)
																																.addGap(
																																		65))
																												.addGroup(
																														GroupLayout.Alignment.LEADING,
																														panelLayout3
																																.createSequentialGroup()
																																.addGroup(
																																		panelLayout3
																																				.createParallelGroup()
																																				.addComponent(
																																						getJCheckBox4(),
																																						GroupLayout.Alignment.LEADING,
																																						GroupLayout.PREFERRED_SIZE,
																																						GroupLayout.PREFERRED_SIZE,
																																						GroupLayout.PREFERRED_SIZE)
																																				.addGroup(
																																						GroupLayout.Alignment.LEADING,
																																						panelLayout3
																																								.createSequentialGroup()
																																								.addComponent(
																																										botaoDom,
																																										GroupLayout.PREFERRED_SIZE,
																																										67,
																																										GroupLayout.PREFERRED_SIZE)
																																								.addGap(
																																										27))
																																				.addGroup(
																																						GroupLayout.Alignment.LEADING,
																																						panelLayout3
																																								.createSequentialGroup()
																																								.addComponent(
																																										getJCheckBox1(),
																																										GroupLayout.PREFERRED_SIZE,
																																										GroupLayout.PREFERRED_SIZE,
																																										GroupLayout.PREFERRED_SIZE)
																																								.addGap(
																																										21))
																																				.addGroup(
																																						GroupLayout.Alignment.LEADING,
																																						panelLayout3
																																								.createSequentialGroup()
																																								.addComponent(
																																										getJCheckBox2(),
																																										GroupLayout.PREFERRED_SIZE,
																																										GroupLayout.PREFERRED_SIZE,
																																										GroupLayout.PREFERRED_SIZE)
																																								.addGap(
																																										6))
																																				.addGroup(
																																						GroupLayout.Alignment.LEADING,
																																						panelLayout3
																																								.createSequentialGroup()
																																								.addComponent(
																																										getJCheckBox5(),
																																										GroupLayout.PREFERRED_SIZE,
																																										GroupLayout.PREFERRED_SIZE,
																																										GroupLayout.PREFERRED_SIZE)
																																								.addGap(
																																										6))
																																				.addGroup(
																																						GroupLayout.Alignment.LEADING,
																																						panelLayout3
																																								.createSequentialGroup()
																																								.addComponent(
																																										getJCheckBox6(),
																																										GroupLayout.PREFERRED_SIZE,
																																										GroupLayout.PREFERRED_SIZE,
																																										GroupLayout.PREFERRED_SIZE)
																																								.addGap(
																																										28)))
																																.addComponent(
																																		botaoSeg,
																																		GroupLayout.PREFERRED_SIZE,
																																		67,
																																		GroupLayout.PREFERRED_SIZE)))))
																.addGap(21)
																.addGroup(
																		panelLayout3
																				.createParallelGroup()
																				.addGroup(
																						panelLayout3
																								.createSequentialGroup()
																								.addGap(
																										0,
																										0,
																										Short.MAX_VALUE)
																								.addComponent(
																										getJTextArea1(),
																										GroupLayout.PREFERRED_SIZE,
																										484,
																										GroupLayout.PREFERRED_SIZE))
																				.addGroup(
																						GroupLayout.Alignment.LEADING,
																						panelLayout3
																								.createSequentialGroup()
																								.addPreferredGap(
																										getJTextArea1(),
																										botaoTer,
																										LayoutStyle.ComponentPlacement.INDENT)
																								.addComponent(
																										botaoTer,
																										GroupLayout.PREFERRED_SIZE,
																										88,
																										GroupLayout.PREFERRED_SIZE)
																								.addGap(
																										25)
																								.addGroup(
																										panelLayout3
																												.createParallelGroup()
																												.addGroup(
																														GroupLayout.Alignment.LEADING,
																														panelLayout3
																																.createSequentialGroup()
																																.addGap(
																																		0,
																																		0,
																																		Short.MAX_VALUE)
																																.addComponent(
																																		botaoQuarta,
																																		GroupLayout.PREFERRED_SIZE,
																																		72,
																																		GroupLayout.PREFERRED_SIZE)
																																.addGap(
																																		30)
																																.addComponent(
																																		botaoQui,
																																		GroupLayout.PREFERRED_SIZE,
																																		72,
																																		GroupLayout.PREFERRED_SIZE))
																												.addGroup(
																														GroupLayout.Alignment.LEADING,
																														panelLayout3
																																.createSequentialGroup()
																																.addGap(
																																		69)
																																.addComponent(
																																		anterior,
																																		GroupLayout.PREFERRED_SIZE,
																																		105,
																																		GroupLayout.PREFERRED_SIZE)))
																								.addGap(
																										17)
																								.addGroup(
																										panelLayout3
																												.createParallelGroup()
																												.addGroup(
																														GroupLayout.Alignment.LEADING,
																														panelLayout3
																																.createSequentialGroup()
																																.addComponent(
																																		botaoSex,
																																		GroupLayout.PREFERRED_SIZE,
																																		72,
																																		GroupLayout.PREFERRED_SIZE)
																																.addPreferredGap(
																																		LayoutStyle.ComponentPlacement.UNRELATED)
																																.addComponent(
																																		botaoSab,
																																		GroupLayout.PREFERRED_SIZE,
																																		72,
																																		GroupLayout.PREFERRED_SIZE))
																												.addGroup(
																														GroupLayout.Alignment.LEADING,
																														panelLayout3
																																.createSequentialGroup()
																																.addComponent(
																																		proximo,
																																		GroupLayout.PREFERRED_SIZE,
																																		103,
																																		GroupLayout.PREFERRED_SIZE)
																																.addGap(
																																		52)))
																								.addGap(
																										13)))))
								.addContainerGap(68, 68));
				panelLayout3
						.setVerticalGroup(panelLayout3
								.createSequentialGroup()
								.addContainerGap(23, 23)
								.addComponent(getTrabalho(),
										GroupLayout.PREFERRED_SIZE, 24,
										GroupLayout.PREFERRED_SIZE)
								.addGroup(
										panelLayout3
												.createParallelGroup()
												.addComponent(
														getJTextArea1(),
														GroupLayout.Alignment.LEADING,
														GroupLayout.PREFERRED_SIZE,
														131,
														GroupLayout.PREFERRED_SIZE)
												.addGroup(
														GroupLayout.Alignment.LEADING,
														panelLayout3
																.createSequentialGroup()
																.addGap(17)
																.addComponent(
																		getJCheckBox1(),
																		GroupLayout.PREFERRED_SIZE,
																		GroupLayout.PREFERRED_SIZE,
																		GroupLayout.PREFERRED_SIZE)
																.addGap(14)
																.addComponent(
																		getJCheckBox1x(),
																		GroupLayout.PREFERRED_SIZE,
																		GroupLayout.PREFERRED_SIZE,
																		GroupLayout.PREFERRED_SIZE)
																.addComponent(
																		limpar,
																		GroupLayout.PREFERRED_SIZE,
																		0,
																		GroupLayout.PREFERRED_SIZE)
																.addGap(15)
																.addComponent(
																		getJCheckBox2(),
																		GroupLayout.PREFERRED_SIZE,
																		GroupLayout.PREFERRED_SIZE,
																		GroupLayout.PREFERRED_SIZE)
																.addGap(13)
																.addComponent(
																		getJCheckBox3(),
																		GroupLayout.PREFERRED_SIZE,
																		GroupLayout.PREFERRED_SIZE,
																		GroupLayout.PREFERRED_SIZE)))
								.addGap(13)
								.addComponent(getJCheckBox4(),
										GroupLayout.PREFERRED_SIZE,
										GroupLayout.PREFERRED_SIZE,
										GroupLayout.PREFERRED_SIZE)
								.addGap(15)
								.addComponent(getJCheckBox5(),
										GroupLayout.PREFERRED_SIZE,
										GroupLayout.PREFERRED_SIZE,
										GroupLayout.PREFERRED_SIZE)
								.addGap(16)
								.addComponent(getJCheckBox6(),
										GroupLayout.PREFERRED_SIZE,
										GroupLayout.PREFERRED_SIZE,
										GroupLayout.PREFERRED_SIZE)
								.addGap(0, 51, Short.MAX_VALUE)
								.addComponent(getNomehorarios(),
										GroupLayout.PREFERRED_SIZE, 20,
										GroupLayout.PREFERRED_SIZE)
								.addGap(20)
								.addGroup(
										panelLayout3
												.createParallelGroup(
														GroupLayout.Alignment.BASELINE)
												.addComponent(
														botaoQuarta,
														GroupLayout.Alignment.BASELINE,
														GroupLayout.PREFERRED_SIZE,
														34,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(
														botaoSex,
														GroupLayout.Alignment.BASELINE,
														GroupLayout.PREFERRED_SIZE,
														29,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(
														botaoQui,
														GroupLayout.Alignment.BASELINE,
														GroupLayout.PREFERRED_SIZE,
														32,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(
														botaoTer,
														GroupLayout.Alignment.BASELINE,
														GroupLayout.PREFERRED_SIZE,
														34,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(
														botaoSab,
														GroupLayout.Alignment.BASELINE,
														GroupLayout.PREFERRED_SIZE,
														31,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(
														botaoDom,
														GroupLayout.Alignment.BASELINE,
														GroupLayout.PREFERRED_SIZE,
														34,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(
														botaoSeg,
														GroupLayout.Alignment.BASELINE,
														GroupLayout.PREFERRED_SIZE,
														33,
														GroupLayout.PREFERRED_SIZE))
								.addGap(49)
								.addGroup(
										panelLayout3
												.createParallelGroup(
														GroupLayout.Alignment.BASELINE)
												.addComponent(
														anterior,
														GroupLayout.Alignment.BASELINE,
														GroupLayout.PREFERRED_SIZE,
														28,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(
														proximo,
														GroupLayout.Alignment.BASELINE,
														GroupLayout.PREFERRED_SIZE,
														26,
														GroupLayout.PREFERRED_SIZE))
								.addContainerGap(92, 92));
			}

			{

			}

			mostraNaTela(frame3);
		}
	}

	/**
	 * Executa a ultima etapa do cadastro. Mostra os dados na tela e salva em
	 * arquivo.
	 */
	public void ultimaEtapa() {
		frame4 = new JFrame("Ultima Etapa - Guardando Dados");
		final JPanel panel = new JPanel();
		GroupLayout panelLayout4 = new GroupLayout((JComponent) panel);
		panel.setLayout(panelLayout4);

		anterior = new JButton("<- Anterior");
		anterior.setForeground(new java.awt.Color(85, 232, 85));
		anterior.setBackground(new java.awt.Color(14, 71, 14));
		String texto = "Clinica a ser cadastrada\n\n";
		List<String> dados = new ArrayList<String>();
		dados.add("Nome da Clinica: ");
		dados.add("Endereco: ");
		dados.add("Telefone: ");
		for (int i = 0; i < 3; i++) {
			texto += "\n" + dados.get(i) + minhaClinica.get(i);
		}
		getAboutClinica().setText(texto);
		dados.clear();
		texto = "Medico a ser cadastrado\n\n";
		dados.add("Nome: ");
		dados.add("CPF: ");
		dados.add("Endereco: ");
		for (int i = 0; i < 3; i++) {
			texto += "\n" + dados.get(i) + meuMedico.get(i);
		}
		getJTextArea2().setText(texto);

		{
			finalizar = new JButton("Finalizar");
			finalizar.setForeground(new java.awt.Color(85, 232, 85));
			finalizar.setBackground(new java.awt.Color(14, 71, 14));
			finalizar.addActionListener((new java.awt.event.ActionListener() {
				@Override
				public void actionPerformed(ActionEvent arg0) {
					try {
						if (tDom.isSelected())
							Configuracoes.salvaHorarios(Calendar.SUNDAY, hDom);
						if (trabalhaSegunda.isSelected())
							Configuracoes.salvaHorarios(Calendar.MONDAY, hSeg);
						if (trabalhaTerca.isSelected())
							Configuracoes.salvaHorarios(Calendar.TUESDAY, hTer);
						if (trabalhaQuarta.isSelected())
							Configuracoes.salvaHorarios(Calendar.WEDNESDAY,
									hQua);
						if (trabalhaQuinta.isSelected())
							Configuracoes
									.salvaHorarios(Calendar.THURSDAY, hQui);
						if (trabalhaSexta.isSelected())
							Configuracoes.salvaHorarios(Calendar.FRIDAY, hSex);
						if (trabalhaSabado.isSelected())
							Configuracoes
									.salvaHorarios(Calendar.SATURDAY, hSab);
						Configuracoes.salvaDados(minhaClinica, meuMedico);
						if (executa.isSelected())
							MenuInicial.main(null);
						
						frame5.setVisible(false);
					} catch (Exception e) {
						
					}
				}

			}));
		}
		panelLayout4
				.setVerticalGroup(panelLayout4
						.createSequentialGroup()
						.addContainerGap(48, 48)
						.addGroup(
								panelLayout4
										.createParallelGroup()
										.addGroup(
												GroupLayout.Alignment.LEADING,
												panelLayout4
														.createSequentialGroup()
														.addComponent(
																getSaudacao4(),
																GroupLayout.PREFERRED_SIZE,
																51,
																GroupLayout.PREFERRED_SIZE)
														.addGap(7))
										.addComponent(getInformacao(),
												GroupLayout.Alignment.LEADING,
												GroupLayout.PREFERRED_SIZE, 58,
												GroupLayout.PREFERRED_SIZE))
						.addGroup(
								panelLayout4
										.createParallelGroup()
										.addGroup(
												GroupLayout.Alignment.LEADING,
												panelLayout4
														.createSequentialGroup()
														.addComponent(
																getAboutClinica(),
																GroupLayout.PREFERRED_SIZE,
																151,
																GroupLayout.PREFERRED_SIZE)
														.addGap(6))
										.addGroup(
												GroupLayout.Alignment.LEADING,
												panelLayout4
														.createSequentialGroup()
														.addGap(11)
														.addComponent(
																getJTextArea2(),
																GroupLayout.PREFERRED_SIZE,
																146,
																GroupLayout.PREFERRED_SIZE)))
						.addGap(179).addComponent(getExecuta(),
								GroupLayout.PREFERRED_SIZE, 21,
								GroupLayout.PREFERRED_SIZE).addGap(15)
						.addGroup(
								panelLayout4.createParallelGroup(
										GroupLayout.Alignment.BASELINE)
										.addComponent(anterior,
												GroupLayout.Alignment.BASELINE,
												GroupLayout.PREFERRED_SIZE, 29,
												GroupLayout.PREFERRED_SIZE)
										.addComponent(finalizar,
												GroupLayout.Alignment.BASELINE,
												GroupLayout.PREFERRED_SIZE, 29,
												GroupLayout.PREFERRED_SIZE))
						.addContainerGap(63, 63));
		panelLayout4
				.setHorizontalGroup(panelLayout4
						.createSequentialGroup()
						.addContainerGap()
						.addGroup(
								panelLayout4
										.createParallelGroup()
										.addGroup(
												GroupLayout.Alignment.LEADING,
												panelLayout4
														.createSequentialGroup()
														.addComponent(
																getSaudacao4(),
																GroupLayout.PREFERRED_SIZE,
																334,
																GroupLayout.PREFERRED_SIZE)
														.addPreferredGap(
																LayoutStyle.ComponentPlacement.RELATED)
														.addComponent(
																getInformacao(),
																GroupLayout.PREFERRED_SIZE,
																388,
																GroupLayout.PREFERRED_SIZE)
														.addGap(0, 0,
																Short.MAX_VALUE))
										.addGroup(
												panelLayout4
														.createSequentialGroup()
														.addPreferredGap(
																getSaudacao4(),
																getAboutClinica(),
																LayoutStyle.ComponentPlacement.INDENT)
														.addGroup(
																panelLayout4
																		.createParallelGroup()
																		.addGroup(
																				GroupLayout.Alignment.LEADING,
																				panelLayout4
																						.createSequentialGroup()
																						.addComponent(
																								getAboutClinica(),
																								GroupLayout.PREFERRED_SIZE,
																								276,
																								GroupLayout.PREFERRED_SIZE)
																						.addGap(
																								64)
																						.addComponent(
																								getJTextArea2(),
																								GroupLayout.PREFERRED_SIZE,
																								313,
																								GroupLayout.PREFERRED_SIZE)
																						.addGap(
																								0,
																								11,
																								Short.MAX_VALUE))
																		.addGroup(
																				GroupLayout.Alignment.LEADING,
																				panelLayout4
																						.createSequentialGroup()
																						.addComponent(
																								getExecuta(),
																								GroupLayout.PREFERRED_SIZE,
																								371,
																								GroupLayout.PREFERRED_SIZE)
																						.addGap(
																								68)
																						.addComponent(
																								anterior,
																								GroupLayout.PREFERRED_SIZE,
																								99,
																								GroupLayout.PREFERRED_SIZE)
																						.addGap(
																								31)
																						.addComponent(
																								finalizar,
																								GroupLayout.PREFERRED_SIZE,
																								95,
																								GroupLayout.PREFERRED_SIZE)
																						.addGap(
																								0,
																								0,
																								Short.MAX_VALUE)))
														.addGap(52)))
						.addContainerGap(50, 50));
		frame4.add(panel);
		panel.setBackground(new java.awt.Color(191, 236, 191));
		mostraNaTela(frame4);

		anterior.addActionListener((new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				frame4.setVisible(false);
				terceiraEtapa();
			}

		}));
	}

	public void capturaHorarios(final List<String> listaDia) {
		frame5 = new JFrame("Configurando horarios do dia");
		frame5.setBounds(0, 0, 800, 600);
		{
			final JPanel panelDoDia = new JPanel();
			frame5.getContentPane().add(panelDoDia);
			panelDoDia.setLayout(null);
			panelDoDia.setSize(500, 300);
			panelDoDia.setBackground(new java.awt.Color(191, 236, 191));

			frame5.setSize(530, 370);
			posicaoX = 112;
			posicaoY = 42;
			final List<JTextField> campos = new ArrayList<JTextField>();

			if (listaDia.isEmpty()) {
				JTextField campoEntrada = new JTextField();
				campoEntrada.setBounds(posicaoX, posicaoY, 72, 21);
				campos.add(campoEntrada);
				posicaoX += 100;
				JTextField campoSaida = new JTextField();
				campoSaida.setBounds(posicaoX, posicaoY, 72, 21);
				campos.add(campoSaida);
				posicaoX -= 100;
				posicaoY += 50;
				listaDia.add("");
				listaDia.add("");
			} else {
				if (campos.isEmpty()) {
					for (int i = 0; i < listaDia.size(); i += 2) {
						JFormattedTextField campoEntrada = new JFormattedTextField(createFormatter("##:##"));
						campoEntrada.setBounds(posicaoX, posicaoY, 72, 21);
						campos.add(campoEntrada);
						posicaoX += 100;
						JFormattedTextField campoSaida = new JFormattedTextField(createFormatter("##:##"));
						campoSaida.setBounds(posicaoX, posicaoY, 72, 21);
						campos.add(campoSaida);
						posicaoX -= 100;
						posicaoY += 50;
					}
				}
			}

			for (int i = 0; i < campos.size(); i++) {
				campos.get(i).setText(listaDia.get(i));
				panelDoDia.add(campos.get(i));
			}
			mostraNaTela(frame5);

			JButton mais = new JButton("Adicionar mais Horários");
			panelDoDia.add(mais);
			mais.setBounds(528, 326, 226, 29);
			mais.setForeground(new java.awt.Color(144, 238, 144));
			mais.setBackground(new java.awt.Color(35, 104, 35));
			mais.addActionListener((new java.awt.event.ActionListener() {
				@Override
				public void actionPerformed(ActionEvent arg0) {
					JTextField campoEntrada = new JTextField();
					campoEntrada.setBounds(posicaoX, posicaoY, 72, 21);
					campos.add(campoEntrada);
					posicaoX += 100;
					JTextField campoSaida = new JTextField();
					campoSaida.setBounds(posicaoX, posicaoY, 72, 21);
					campos.add(campoSaida);
					posicaoX -= 100;
					posicaoY += 50;
					listaDia.add("");
					listaDia.add("");
					panelDoDia.add(campoEntrada);
					panelDoDia.add(campoSaida);
					frame5.remove(panelDoDia);
					frame5.add(panelDoDia);
					frame5.setVisible(false);
					frame5.setVisible(true);
				}

			}));

			{
				JButton limpa = new JButton("Limpar");
				panelDoDia.add(limpa);
				limpa.setBounds(565, 383, 157, 36);
				limpa.setForeground(new java.awt.Color(144, 238, 144));
				limpa.setBackground(new java.awt.Color(35, 104, 35));
				limpa.addActionListener((new java.awt.event.ActionListener() {
					@Override
					public void actionPerformed(ActionEvent arg0) {
						for (JTextField jt : campos) {
							jt.setText("");
						}
					}

				}));
			}
			{
				JButton ok = new JButton("Salvar");
				panelDoDia.add(ok);
				ok.setBounds(565, 430, 157, 33);
				ok.setForeground(new java.awt.Color(144, 238, 144));
				ok.setBackground(new java.awt.Color(35, 104, 35));
				ok.addActionListener((new java.awt.event.ActionListener() {
					@Override
					public void actionPerformed(ActionEvent arg0) {
						for (int j = 0; j < campos.size(); j += 2) {
							if (!campos.get(j).getText().equals("")
									|| !campos.get(j + 1).getText().equals("")) {

								if (Verificador.verificaTempo(campos.get(j)
										.getText()
										+ ":00")
										&& Verificador.verificaTempo(campos
												.get(j + 1).getText()
												+ ":00")) {
									listaDia.add(j, campos.get(j).getText());
									listaDia.remove(j + 1);
									listaDia.add(j + 1, campos.get(j + 1)
											.getText());
									listaDia.remove(j + 2);
								} else {
									listaDia.add("");
									listaDia.add("");
									for (int i = 0; i < listaDia.size(); i++) {
										listaDia.add(i, "");
										listaDia.remove(i + 1);
									}
									JOptionPane.showMessageDialog(panelDoDia,
											"Formato de horario invalido",
											"Atenção!",
											JOptionPane.PLAIN_MESSAGE);
								}
							}
						}
					}

				}));
			}
			{
				JButton close = new JButton("Fechar");
				panelDoDia.add(close);
				panelDoDia.add(getLabelEntrada());
				panelDoDia.add(getLabelSaida());
				panelDoDia.add(getExplicacao());
				close.setBounds(565, 474, 157, 31);
				close.setForeground(new java.awt.Color(144, 238, 144));
				close.setBackground(new java.awt.Color(35, 104, 35));
				close.addActionListener((new java.awt.event.ActionListener() {
					@Override
					public void actionPerformed(ActionEvent arg0) {
						frame5.setVisible(false);
					}

				}));
			}
		}

	}

	private void mostraNaTela(JFrame frame) {
		frame.pack();
		frame.setSize(800, 600);
		frame.setLocationRelativeTo(null);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setLayout(new java.awt.GridLayout(0, 1));
		frame.setVisible(true);
	}

	private void criaClinica(String nome, String endereco, String telefone)
			throws Exception {
		if (!Verificador.verificaNome(nome))
			throw new Exception("Nome invalido");
		if (!Verificador.verificaEndereco(endereco))
			throw new Exception("Endereço invalido");
		if (!Verificador.verificaTelefone(telefone))
			throw new Exception("Telefone invalido");

		if (minhaClinica == null) {
			minhaClinica = new ArrayList<String>();
		}
		minhaClinica.clear();
		minhaClinica.add(nome);
		minhaClinica.add(endereco);
		minhaClinica.add(telefone);
	}

	private void criaMedico(String nome, String cpf, String endereco,
			String email, String telefone, String sexo, String data,
			String consulta, String retorno) throws Exception {
		if (!Verificador.verificaNome(nome))
			throw new Exception("Nome invalido");
		if (!Verificador.verificaCpf(cpf))
			throw new Exception("CPF invalido");
		if (!Verificador.verificaEndereco(endereco))
			throw new Exception("Endereço invalido");
		if (!Verificador.verificaTelefone(telefone))
			throw new Exception("Telefone invalido");
		if (!Verificador.verificaEmail(email))
			throw new Exception("Email invalido");
		if (!Verificador.verificaData(data))
			throw new Exception("Data de nascimento com formato invalido");
		if (!Verificador.verificaTempo(consulta + ":00"))
			throw new Exception("Horário de consulta com formato invalido");
		if (!Verificador.verificaTempo(retorno + ":00"))
			throw new Exception("Horário de retorno com formato invalido");

		if (meuMedico == null) {
			meuMedico = new ArrayList<String>();
		}
		meuMedico.clear();
		meuMedico.add(nome);
		meuMedico.add(cpf);
		meuMedico.add(endereco);
		meuMedico.add(email);
		meuMedico.add(telefone);
		meuMedico.add(sexo);
		meuMedico.add(data);
		meuMedico.add(consulta + ":00");
		meuMedico.add(retorno + ":00");

	}

	private JLabel getNomehorarios() {
		if (nomehorarios == null) {
			nomehorarios = new JLabel();
			nomehorarios.setText("Horários (hh:mm) :");
			nomehorarios.setFont(new java.awt.Font("Dialog", 1, 12));
		}
		return nomehorarios;
	}

	private JLabel getLabelEntrada() {
		if (labelEntrada == null) {
			labelEntrada = new JLabel();
			labelEntrada.setText("Horario de Entrada (hh:mm)");
			labelEntrada.setBounds(12, 22, 199, 14);
		}
		return labelEntrada;
	}

	private JLabel getLabelSaida() {
		if (labelSaida == null) {
			labelSaida = new JLabel();
			labelSaida.setText("Horario de Saida (hh:mm)");
			labelSaida.setBounds(223, 22, 211, 14);
		}
		return labelSaida;
	}

	private JCheckBox getJCheckBox1() {
		if (tDom == null) {
			tDom = new JCheckBox();
			tDom.setText("Domingo");
			tDom.setOpaque(false);
		}
		return tDom;
	}

	private JCheckBox getJCheckBox1x() {
		if (trabalhaSegunda == null) {
			trabalhaSegunda = new JCheckBox();
			trabalhaSegunda.setText("Segunda-Feira");
			trabalhaSegunda.setOpaque(false);
		}
		return trabalhaSegunda;
	}

	private JCheckBox getJCheckBox2() {
		if (trabalhaTerca == null) {
			trabalhaTerca = new JCheckBox();
			trabalhaTerca.setText("Terça-Feira");
			trabalhaTerca.setOpaque(false);
		}
		return trabalhaTerca;
	}

	private JCheckBox getJCheckBox3() {
		if (trabalhaQuarta == null) {
			trabalhaQuarta = new JCheckBox();
			trabalhaQuarta.setText("Quarta-Feira");
			trabalhaQuarta.setOpaque(false);
		}
		return trabalhaQuarta;
	}

	private JCheckBox getJCheckBox4() {
		if (trabalhaQuinta == null) {
			trabalhaQuinta = new JCheckBox();
			trabalhaQuinta.setText("Quinta-Feira");
			trabalhaQuinta.setOpaque(false);
		}
		return trabalhaQuinta;
	}

	private JCheckBox getJCheckBox5() {
		if (trabalhaSexta == null) {
			trabalhaSexta = new JCheckBox();
			trabalhaSexta.setText("Sexta-Feira");
			trabalhaSexta.setOpaque(false);
		}
		return trabalhaSexta;
	}

	private JCheckBox getJCheckBox6() {
		if (trabalhaSabado == null) {
			trabalhaSabado = new JCheckBox();
			trabalhaSabado.setText("Sábado");
			trabalhaSabado.setOpaque(false);
		}
		return trabalhaSabado;
	}

	private JLabel getTrabalho() {
		if (trabalho == null) {
			trabalho = new JLabel();
			trabalho.setText("Dias de trabalho:");
			trabalho.setFont(new java.awt.Font("Dialog", 1, 12));
		}
		return trabalho;
	}

	private JTextArea getJTextArea1() {
		if (jTextArea1 == null) {
			jTextArea1 = new JTextArea();
			jTextArea1
					.setText("Está na hora de registrar os dias e horários de trabalho do Médico:\n\nMarque os dias de trabalho na lista da esquerda.\n\nEm seguida clique no dia ao qual você deseja adicionar horários e\nescreva os horários no formato solicitado.\nClique em 'Salvar' e faça o mesmo para os outros dias de trabalho.\nQuando tiver acabado clique em 'Próximo'.\n\n");
			jTextArea1.setOpaque(false);
			jTextArea1.setEditable(false);
			jTextArea1.setFont(new java.awt.Font("Monospaced", 0, 12));
			jTextArea1.setForeground(new java.awt.Color(64, 124, 64));
		}
		return jTextArea1;
	}

	private JTextArea getAboutMedOffice() {
		if (aboutMedOffice == null) {
			aboutMedOffice = new JTextArea();
			aboutMedOffice
					.setText("O Medical Secretary Office System (MedSecret) foi projetado e desenvolvido para\nauxiliar secretárias de quaisquer especialidades médicas.");
			aboutMedOffice.setOpaque(false);
			aboutMedOffice.setEditable(false);
		}
		return aboutMedOffice;
	}

	private JTextArea getProximoPasso() {
		if (proximoPasso == null) {
			proximoPasso = new JTextArea();
			proximoPasso
					.setText("Comece registrando a Clínica e o Médico no nosso sistema.\nPara isso clique em 'P\u0155oximo' e siga as intruções.");
			proximoPasso.setOpaque(false);
			proximoPasso.setEditable(false);
			proximoPasso.setFont(new java.awt.Font("Monospaced", 0, 12));
			proximoPasso.setForeground(new java.awt.Color(64, 124, 64));
		}
		return proximoPasso;
	}

	private JButton getLimpar1() {
		if (limpar1 == null) {
			limpar1 = new JButton();
			limpar1.setText("Limpar");
			limpar1.setBackground(new java.awt.Color(14, 71, 14));
			limpar1.setSize(91, 21);
			limpar1.setForeground(new java.awt.Color(85, 232, 85));
		}
		return limpar1;
	}

	private JTextArea getSaudacao() {
		if (saudacao == null) {
			saudacao = new JTextArea();
			saudacao.setText("1ª etapa: Cadastrando a Clínica");
			saudacao.setEditable(false);
			saudacao.setFont(new java.awt.Font("Purisa", 1, 14));
			saudacao.setOpaque(false);
			saudacao.setForeground(new java.awt.Color(23, 100, 23));
		}
		return saudacao;
	}

	private JTextArea getPasso2() {
		if (passo2 == null) {
			passo2 = new JTextArea();
			passo2
					.setText("Cadastre a Clínica fornecendo os dados pedidos abaixo.\n* Campos obrigatórios\n\nDepois de escrever os dados necessários clique em 'Próximo'.");
			passo2.setOpaque(false);
			passo2.setFont(new java.awt.Font("Monospaced", 0, 12));
			passo2.setForeground(new java.awt.Color(64, 124, 64));
			passo2.setEditable(false);
		}
		return passo2;
	}

	private JTextArea getSaudacao2() {
		if (saudacao2 == null) {
			saudacao2 = new JTextArea();
			saudacao2.setText("2ª etapa: Cadastrando o Médico");
			saudacao2.setOpaque(false);
			saudacao2.setEditable(false);
			saudacao2.setFont(new java.awt.Font("Purisa", 1, 14));
			saudacao2.setForeground(new java.awt.Color(23, 113, 23));
		}
		return saudacao2;
	}

	private JTextArea getPasso3() {
		if (passo3 == null) {
			passo3 = new JTextArea();
			passo3
					.setText("Para cadastrar o Médico informe os dados pedidos\ne clique em 'P\u0155oximo'.\n* Campos obrigatórios");
			passo3.setOpaque(false);
			passo3.setEditable(false);
			passo3.setFont(new java.awt.Font("Monospaced", 0, 12));
			passo3.setForeground(new java.awt.Color(64, 124, 64));
		}
		return passo3;
	}

	private JTextArea getSaudacao4() {
		if (saudacao4 == null) {
			saudacao4 = new JTextArea();
			saudacao4.setText("4ª etapa: Salvando os Dados");
			saudacao4.setEditable(false);
			saudacao4.setFont(new java.awt.Font("Purisa", 1, 14));
			saudacao4.setOpaque(false);
			saudacao4.setForeground(new java.awt.Color(16, 97, 16));
		}
		return saudacao4;
	}

	private JTextArea getInformacao() {
		if (informacao == null) {
			informacao = new JTextArea();
			informacao
					.setText("Dados recebidos com sucesso.\nClique em 'Finalizar' para salvar os dados no sistema.");
			informacao.setEditable(false);
			informacao.setOpaque(false);
			informacao.setFont(new java.awt.Font("Monospaced", 0, 12));
			informacao.setForeground(new java.awt.Color(64, 124, 64));
		}
		return informacao;
	}

	private JCheckBox getExecuta() {
		if (executa == null) {
			executa = new JCheckBox();
			executa.setText("Executar MedOffice depois de salvar os dados");
			executa.setOpaque(false);
		}
		return executa;
	}

	private JTextArea getAboutClinica() {
		if (aboutClinica == null) {
			aboutClinica = new JTextArea();
			aboutClinica.setOpaque(false);
		}
		return aboutClinica;
	}

	private JTextArea getJTextArea2() {
		if (aboutMedico == null) {
			aboutMedico = new JTextArea();
			aboutMedico.setOpaque(false);
		}
		return aboutMedico;
	}

	private JButton getLimpa2() {

		if (limpa2 == null) {
			limpa2 = new JButton();
			limpa2.setText("Limpar");
			limpa2.setBackground(new java.awt.Color(14, 71, 14));
			limpa2.setForeground(new java.awt.Color(85, 232, 85));
		}
		return limpa2;
	}


	private JRadioButton getSexoF() {
		if (sexoF == null) {
			sexoF = new JRadioButton();
			sexoF.setText("Feminino");
			sexoF.setOpaque(false);
		}
		return sexoF;
	}

	private JRadioButton getSexoM() {
		if (sexoM == null) {
			sexoM = new JRadioButton();
			sexoM.setText("Masculino");
			sexoM.setOpaque(false);
		}
		return sexoM;
	}

	private ButtonGroup getEscolhaSexo() {
		if (escolhaSexo == null) {
			escolhaSexo = new ButtonGroup();
		}
		return escolhaSexo;
	}

	public boolean executar() {
		return executarDepois;
	}

	private JTextArea getExplicacao() {
		if (explicacao == null) {
			explicacao = new JTextArea();
			explicacao
					.setText("Adicione os Horários ao dia:\n\nEscreva o horário de entrada e de saída no formato\nsolicitado (hh:mm);\nCaso queira adicionar mais horários para esse dia\nclique em 'Adicionar mais Horários';\nUm par de horários (entrada e saída) deixado em\nbranco não será contabilizado;\nApós informar os horários clique em 'Salvar';\nQuando terminar clique em 'Fechar';\n");
			explicacao.setBounds(379, 75, 369, 188);
			explicacao.setEditable(false);
			explicacao.setForeground(new java.awt.Color(64, 124, 64));
			explicacao.setOpaque(false);
			explicacao.setFont(new java.awt.Font("Monospaced", 0, 12));
		}
		return explicacao;
	}
	
	/**
	 * retirado de:
	 * <u>http://java.sun.com/docs/books/tutorial/uiswing/components
	 * /formattedtextfield.html</u>
	 */
	private MaskFormatter createFormatter(String s) {
		MaskFormatter formatter = null;
		try {
			formatter = new MaskFormatter(s);
			formatter.setPlaceholderCharacter('_');
		} catch (java.text.ParseException exc) {
			System.err.println("Formatacao invalida: " + exc.getMessage());
			System.exit(-1);
		}
		return formatter;
	}
	

}
